﻿Public Class UsuarioNegocio

    Public Function listar() As Collection
        Dim dao As New UsuarioDAO
        Return dao.listar()
    End Function

    Public Function insertar(ByVal nombre As String, ByVal apellido As String,
                             ByVal telefono As Integer, ByVal correo As String,
                             ByVal sexo As String, ByVal pass As String) As Usuario

        Dim modelo As New Usuario()

        modelo.nombre = nombre
        modelo.apellido = apellido
        modelo.telefono = telefono
        modelo.correo = correo
        modelo.sexo = sexo
        modelo.pass = pass

        Dim dao As New UsuarioDAO
        Return dao.insertar(modelo)
    End Function

    Public Sub actualizar(ByVal idUsuario As Integer, ByVal nombre As String, ByVal apellido As String, ByVal telefono As Integer, ByVal correo As String, ByVal sexo As String, ByVal pass As String)

        Dim modelo As New Usuario()
        modelo.idUsuario = idUsuario
        modelo.nombre = nombre
        modelo.apellido = apellido
        modelo.telefono = telefono
        modelo.correo = correo
        modelo.sexo = sexo
        modelo.pass = pass

        Dim dao As New UsuarioDAO
        dao.actualizar(modelo)
    End Sub

    Public Sub eliminar(ByVal idUsuario As Integer)
        Dim dao As New UsuarioDAO
        dao.eliminar(idUsuario)
    End Sub

    Public Function obtener(ByVal idUsuario As Integer) As Usuario
        Dim dao As New UsuarioDAO
        Return dao.obtener(idUsuario)
    End Function

    Public Function buscarPorNombre(ByVal nombre As String) As Collection
        Dim dao As New UsuarioDAO
        Return dao.buscarPorNombre(nombre)
    End Function

    Public Function logear(ByVal correo As String, ByVal pass As String)

        Dim modelo As New Usuario()
        modelo.correo = correo
        modelo.pass = pass

        Dim dao As New UsuarioDAO()
        Return dao.logear(modelo)
    End Function

End Class
